<?php

/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', FALSE);
ini_set('display_startup_errors', FALSE);
date_default_timezone_set('Europe/London');

define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');

/** Include PHPExcel */
require_once dirname(__FILE__) . '/library/PHPExcel/Classes/PHPExcel/IOFactory.php';

$ean_file_name = 'EAN_code.xlsx';

if (file_exists($ean_file_name)) {
    $objPHPExcel = PHPExcel_IOFactory::load($ean_file_name);
} else {
    $objPHPExcel = new PHPExcel();
}

$objPHPExcel->setActiveSheetIndex(0);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $ean_file_name . '"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');



